function [localSequence, correspondingTriangles]=addPoint(localSequence, sites, triangles, triangleGrid)

correspondingTriangles=findLocalTriangle(localSequence,sites, triangles, triangleGrid);
N=size(localSequence,2);

for i=2:2:(N-3)
    P=localSequence(:,i);
    Q=localSequence(:,i+1);
    R=localSequence(:,i+2);
    [t, pt]=violation(P,Q,R, sites, triangles, triangleGrid);
    if ~isempty(t)
        theTriangle=findLocalTriangle(pt, sites,triangles, triangleGrid);
        if t<0.5
            correspondingTriangles=[correspondingTriangles(1:i), theTriangle, theTriangle, correspondingTriangles(i+1:end)];
            localSequence=[localSequence(:,1:i), pt, pt, localSequence(:,(i+1):end)];
        else
            correspondingTriangles=[correspondingTriangles(1:i+1), theTriangle, theTriangle, correspondingTriangles(i+2:end)];
            localSequence=[localSequence(:,1:(i+1)), pt, pt, localSequence(:,(i+2):end)];
        end
        return;
    end
end

end